

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加修改</title>
    {include file="include/top"}
    <style>
        .layui-form-item .layui-input-inline{width: 80%;}
        #LAY_layedit_2{background: #fff;}
        .layui-input-inline input{border: 0;margin-right: 20px;text-indent: 10px;}
    </style>
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-app-form-tags" style="padding: 20px 0 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">执行方式</label>
        <div class="layui-input-inline">
            <input type="radio" lay-filter="ctype" name="ctype" value="1" title="统一比例设置" {if !isset($data.ctype)}checked{/if} {if isset($data.ctype) && $data.ctype==1}checked{/if}>
            <input type="radio" lay-filter="ctype" name="ctype" value="2" title="详细周价格" {if isset($data.ctype) && $data.ctype==2}checked{/if}>
        </div>
    </div>
    {include file="include/input" class2='layui-form-item' type='text' title="备注" name='content' value='<?php echo isset($data["content"])?$data["content"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='datetime-local' title="执行时间" name='taskTime' value='<?php echo isset($data["taskTime"])?$data["taskTime"]:"";?>'}
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <select name="status" lay-search="" lay-filter="status" lay-search>
                <option value="0" <?php if(isset($data['status']) && $data['status']==0){ echo 'selected';}?>>待执行</option>
                <option value="1" <?php if(isset($data['status']) && $data['status']==1){ echo 'selected';}?>>已执行</option>
                <option value="-1" <?php if(isset($data['status']) && $data['status']==-1){ echo 'selected';}?>>停用</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">执行标签</label>
        <div class="layui-input-inline">
            <div class="layui-btn-container">
                <button type="button" class="layui-btn" lay-demotransferactive="reload">重置</button>
            </div>

            <div id="selectTips" class="demo-transfer"></div>
        </div>
    </div>
    <span id="percentSet" {if isset($data.ctype) && $data.ctype==2} style="display: none;" {/if}>
        {include file="include/input" class2='layui-form-item' type='text' title="让利%" name='percent' value='<?php echo isset($data["percent"])?$data["percent"]:"";?>'}
    </span>
    <span id="weekPriceSet" {if !isset($data.ctype)} style="display: none;" {/if} {if isset($data.ctype) && $data.ctype==1} style="display: none;" {/if}>
        <div class="layui-form-item">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline" style="display: flex;">
            <input type="text" value="周日" readonly>
            <input type="text" value="周一" readonly>
            <input type="text" value="周二" readonly>
            <input type="text" value="周三" readonly>
            <input type="text" value="周四" readonly>
            <input type="text" value="周五" readonly>
            <input type="text" value="周六" readonly>
        </div>
    </div>
        {if isset($data.rule) && is_array($data.rule)}
    {foreach $data['rule'] as $v}
    <div class="layui-form-item priceList" >
        <label class="layui-form-label">{$v[0]}</label>
        <div class="layui-input-inline" style="display: flex">
            <input type="number" name="a0" value="{$v[1]}" placeholder="请输入..." autocomplete="off">
            <input type="number" name="a1" value="{$v[2]}" placeholder="请输入..." autocomplete="off">
            <input type="number" name="a2" value="{$v[3]}" placeholder="请输入..." autocomplete="off">
            <input type="number" name="a3" value="{$v[4]}" placeholder="请输入..." autocomplete="off">
            <input type="number" name="a4" value="{$v[5]}" placeholder="请输入..." autocomplete="off">
            <input type="number" name="a5" value="{$v[6]}" placeholder="请输入..." autocomplete="off">
            <input type="number" name="a6" value="{$v[7]}" placeholder="请输入..." autocomplete="off">
        </div>
    </div>
    {/foreach}
    {/if}
    </span>
    <input name="tipsIDS" type="hidden" value="{$data.tipsIDS?json_encode($data.tipsIDS):''}">

</div>

{include file="include/js"}
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','layedit','upload','transfer'],function () {
        var $=layui.$;
        var form=layui.form;
        var upload = layui.upload
        var layedit = layui.layedit;
        var transfer = layui.transfer,util = layui.util;
        function getTipsIDS(){
            var getData = transfer.getData('key123'); //获取右侧数据
            $("input[name='tipsIDS']").val(JSON.stringify(getData))
        }
        $(function (){
            setSelect()
            getTipsIDS()
        })
        // 图片接口放到建立编辑器前面，否则无效
        layedit.set({
            uploadImage: {
                url: '/users/uploadimg', //接口url
                type: 'post' //默认post
            }
        });
        // 设置编辑器
        layedit.build('content', {
            height: 500 //设置编辑器高度
            ,background:"#ffffff"
        });
        form.on("radio(ctype)",function (){
            var value = $(this).val()
            if(value==1){
                $("#percentSet").show()
                $("#weekPriceSet").hide()
            }else{
                $("#percentSet").hide()
                $("#weekPriceSet").show()
            }
        })
        var index = layedit.build('content'); //建立编辑器
        form.verify({ // 这里就是把富文本数据同步到<textarea>中
            content: function (value) {
                return layedit.sync(index);
            }
        });
        function setSelect(){
            //实例调用
            transfer.render({
                elem: '#selectTips'
                ,data: {$tipsAllIDS | raw}
                ,id: 'key123' //定义唯一索引
                ,showSearch: true
                ,title: ['可选标签', '已选标签']
                ,width:"40%"
                ,onchange:function (){
                    getTipsIDS()
                }
            })
            {if strlen($data.tipsIDS)>2}
            transfer.reload('key123', {
                value: {$data.tipsIDS | raw}
            })
            {/if}
            }



            //批量办法定事件
            util.event('lay-demoTransferActive', {
                getData: function(othis){
                    var getData = transfer.getData('key123'); //获取右侧数据
                    layer.alert(JSON.stringify(getData));
                }
                ,reload:function(){
                    //实例重载
                    transfer.reload('key123', {
                        value: []
                    })
                    getTipsIDS()
                }
            });
    });
</script>
</body>
</html>